import unittest
from parameterized import parameterized
from login_api import LoginApi
from read_json_data import build_data


class TestLogin(unittest.TestCase):
    @parameterized.expand(build_data('./login.json'))
    def test_login(self, case_name, body, expect):
        # 登录请求
        resp = LoginApi().login(body)
        resp_data = resp.json()

        # 断言
        self.assertEqual(expect.get('status_code'), resp.status_code)
        self.assertEqual(expect.get('success'), resp_data.get('success'))
        self.assertEqual(expect.get('code'), resp_data.get('code'))
        self.assertIn(expect.get('message'), resp_data.get('message'))
